package practica4;

import weka.attributeSelection.BestFirst;
import weka.attributeSelection.CfsSubsetEval;
import weka.core.Instances;
import weka.filters.Filter;
import weka.filters.supervised.attribute.AttributeSelection;
import weka.filters.unsupervised.attribute.Normalize;

public class FeatureSubsetSelection {
	
	public FeatureSubsetSelection(){}
	
	public Instances normalize(Instances pData) throws Exception{
		
		Normalize n = new Normalize();
        n.setInputFormat(pData);
        
        return Normalize.useFilter(pData, n);
		
	}
	
	public Instances atributeSelection(Instances data) throws Exception{
		/////////////////////////////////////////////////////////////		
		// 2. FEATURE SUBSET SELECTION
		//  HACER!!!! Empaquetar Bloque 2: como sub-clase		
		AttributeSelection filter= new AttributeSelection();
		CfsSubsetEval eval = new CfsSubsetEval();
		BestFirst search=new BestFirst();
		filter.setEvaluator(eval);
		filter.setSearch(search);
		filter.setInputFormat(data);
		// 2.1 Get new data set with the attribute sub-set
		Instances newData = Filter.useFilter(data, filter);
		
		return newData;
	}

}
